package com.atguigu.jxc.service.impl;

import com.atguigu.jxc.dao.SupplierDao;
import com.atguigu.jxc.entity.Supplier;
import com.atguigu.jxc.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

@Service
public class SupplierServiceImpl implements SupplierService {
    @Autowired
    private SupplierDao supplierDao;

    @Override
    public Integer count() {
        return supplierDao.count();
    }

    @Override
    public List<Supplier> list(Integer page, Integer rows, String supplierName) {
        return supplierDao.list(page, rows, supplierName);
    }

    @Override
    public Boolean save(Supplier supplier) {
        if (supplier.getSupplierId() != null && supplier.getSupplierId() != 0) {
            // 添加
            return supplierDao.save(supplier);
        } else {
            // 修改
            return supplierDao.updateById(supplier);
        }
    }

    @Override
    public Boolean delete(String ids) {
        return supplierDao.deleteById(ids);
    }
}
